package com.tjsinfo.tjsoa.vote.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.vote.bo.ITVoteOpinionBoxBO;

public class OpinionBoxDelAction extends Action {
	private ITVoteOpinionBoxBO opinionBoxBo;
	public void setOpinionBoxBo(ITVoteOpinionBoxBO opinionBoxBo) {
		this.opinionBoxBo = opinionBoxBo;
	}
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		try {		
			String id = request.getParameter("id");
			String list = request.getParameter("list");
			String linkurl = "vote/opinionBox/opinionBoxAllList.jsp";
			if("self".equals(list)){
				linkurl = "vote/opinionBox/opinionBoxSelfList.jsp";
			}
			
			opinionBoxBo.delete(id);
			
			request.setAttribute("linkurl", linkurl);
			request.setAttribute("message", "vote.opinionBoxDel.message");
			
			return mapping.findForward("success");
		} catch (Exception e) {
			e.printStackTrace();
			return mapping.findForward("failed");
		}
	}
}
